<?php 

class home_model extends CI_Model
{
	function __construct()
	{
		parent::__construct();	
	}
	
	function get_item_cat()
	{
		$this->db->where('IsActive',1);
		return $this->db->get('category')->result();	
	}
	
	function get_bnright()
	{
		$this->db->where('bl_active',1);
		return $this->db->get('banner_right')->result();
	}
	
	function get_bnbottom()
	{
		$this->db->where('bl_active',1);
		return $this->db->get('banner_bottom')->result();
	}
	
	function count_search($keyword)
	{
		$this->db->like('ProductName', $keyword) ;
		//$this->db->or_like('ProductFunc', $keyword) ;
		$this->db->where('bl_active',1) ;
		$query = $this->db->get('product') ;
		return $query->num_rows() ;
	}

	function get_search($keyword, $num=20,$start=0)
	{
		$this->db->like('ProductName', $keyword) ;
		//$this->db->or_like('ProductFunc', $keyword) ;
		$this->db->where('bl_active',1) ;
		$this->db->order_by('Ordering','asc') ;
		$query = $this->db->get('product', $num, $start) ;
		return $query->result() ;
	}
	
	function get_bnmain()
	{
		$this->db->where('bl_active',1);
		$this->db->order_by('BannerID','DESC');
		return $this->db->get('bannermain')->result();
	}
	
	function getCat($num=3)
	{
		$this->db->where('status',1);
		$this->db->order_by('idBannerCat','DESC');
		return $this->db->get('bannermain_cat',$num)->result();
	}
	
	function showBanneCat($bannerId)
	{
		$this->db->where('idBannerCat',$bannerId);
		return $this->db->get('bannermain')->result();	
	}
}
?>
